package org.forum.service.impl;

import java.io.Serializable;
import java.util.List;

import org.forum.dao.IconDao;
import org.forum.dao.UserDao;
import org.forum.domain.Icon;
import org.forum.domain.User;
import org.forum.service.UserInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class UserInfoServiceImpl implements UserInfoService {

	Logger logger = LoggerFactory.getLogger(UserInfoServiceImpl.class);

	//
	public UserDao<User> userDao;

	public void setUserDao(UserDao<User> userDao) {
		this.userDao = userDao;
	}

	//
	public IconDao iconDao;

	public void setIconDao(IconDao iconDao) {
		this.iconDao = iconDao;
	}

	@SuppressWarnings("unchecked")
	@Override
	public boolean isAccountAlreadyExist(User user) {
		User users = (User) userDao.findUserByUsername(user);
		if (userDao.findUserByUsername(user) != null) {
			if (logger.isDebugEnabled()) {
				logger.debug("users[0]:" + user.getUsername() + " " + user.getUserPass());
			}
			return true;
		}
		return false;
	}

	@Override
	public Serializable saveUser(User user) {
		return userDao.saveUser(user);
	}

	@Override
	public void updateUser(User user) {
		userDao.updateUser(user);
	}

	@Override
	public Serializable saveIcon(Icon icon) {
		return iconDao.saveIcon(icon);
	}

}
